/**
 * Created by QDHL on 2017/4/18.
 */

$(document).ready(function () {
    $('#updatepass').click(function () {
        var oldpassword = $('#oldpassword').val();
        var newpassword = $('#newpassword').val();
        var checkpass = $('#checkpass').val();
        if (newpassword != checkpass){
            swal({
                title: "",
                text: "两次密码输入不相同"
            })
        }else{
            $.post("/app/upass/", {
                oldpassword:oldpassword,
                newpassword:newpassword
                }, function(data,status){
                    if (data.status_code == 0){
                        swal({
                            title: "",
                            text: "密码修改成功"
                        },function () {
                            window.location.href = '/accounts/logout/';
                        })
                    }else if (data.status_code == 1){
                        swal({
                            title: "",
                            text: "旧密码验证失败"
                        })
                    }
                },'json'
            );
        }
    });
});